/**
 *
 *
 *
 *
 */


#ifndef BDB_CACHE
#	define BDB_CACHE


// std or boost
#include <boost/format.hpp>

// BDB 
#include <db_cxx.h>


// Configure 
#include "../config.h"

// HappyEngine
#include "../storage_engine/item_data.h"

#ifdef HAPPY_ENGINE
#	include "../storage_engine/HappyEngineOption.h"
#endif


using namespace std;
using boost::format;
using boost::io::group;
using namespace HappyDB::Common;

//#define HAPPY_CACHE


namespace HappyDB
{
	namespace CacheEngine
	{

class CBDBCache
{
public:
	CBDBCache(CHappyEngineOption* pOption);

public:
	structBDBSettings		m_bdbSettings;
	DB*						m_pDB;
	DB_ENV*					m_pDBEnv;
	DB_MPOOL_STAT *			gsp;

	CHappyEngineOption *	m_pOption;

public:
	void BDBSettingsInit(bool bGetOption = true);
	void BDBEnvInit(void);
	void BDBEnvClose(void);
	void BDBOpen();
	void BDBClose();
	void BDBCheckpoint(void);


	int ItemGet(const char * key, u_int32_t nkey, ITEM * p, u_int32_t ulen);
	int ItemPut(const char * key, u_int32_t nkey, ITEM * p);
	int ItemDel(const char * key, u_int32_t nkey);
	int ItemExists(const char * key, u_int32_t nkey);
};


	}
}



#endif